(*Dirichlet conditions*)ss=u/.First@NDSolve[{D[u[x,t],t]==D[u[x,t],x,x],u[x,0]==Sin[x],u[0,t]==0,u[Pi,t]==0},u,{x,0,Pi},{t,0,3}]

list=Table[Plot[ss[x,t],{x,0,Pi},PlotRange->{-1.3,1.3}],{t,0,3,0.05}];

ListAnimate[list]

(*Dirichlet conditions*)

sss=u/.First@NDSolve[{D[u[x,t],t]==D[u[x,t],x,x],u[x,0]==Cos[3x],u[0,t]==1,u[Pi,t]==-1},u,{x,0,Pi},{t,0,0.5}]

list=Table[Plot[sss[x,t],{x,0,Pi},PlotRange->{-1.3,1.3}],{t,0,0.5,0.003}];

ListAnimate[list]

(*Heat sourse with Dirichlet conditions*)s=u/.First@NDSolve[{D[u[x,t],t]==D[u[x,t],x,x]+2,u[x,0]==Sin[x],u[0,t]==0,u[Pi,t]==0},u,{x,0,Pi},{t,0,4}]

list=Table[Plot[s[x,t],{x,0,Pi},PlotRange->{-1.3,5}],{t,0,4,0.05}];

ListAnimate[list]

(*Neumann conditions*)sssss=u/.First@NDSolve[{D[u[x,t],t]==D[u[x,t],x,x],u[x,0]==Cos[x]+1,(D[u[x,t],x]/.x->0)==0,(D[u[x,t],x]/.x->Pi)==0},u,{x,0,Pi},{t,0,1}]

list=Table[Plot[sssss[x,t],{x,0,Pi},PlotRange->{-0.3,2.3}],{t,0,1,0.005}];

ListAnimate[list]

(*Neumann conditions*)ssssss=u/.First@NDSolve[{D[u[x,t],t]==D[u[x,t],x,x]+1,u[x,0]==Cos[x]+1,(D[u[x,t],x]/.x->0)==0,(D[u[x,t],x]/.x->Pi)==0},u,{x,0,Pi},{t,0,1}]

list=Table[Plot[ssssss[x,t],{x,0,Pi},PlotRange->{-0.3,2.3}],{t,0,1,0.005}];

ListAnimate[list]